<template>
	<!-- 供应链 list-->
	<view class="">
		<!-- v-for="(item,index) in list" :class="index%2==0?'ecpire':''" -->
		<view class="item" v-for="(item,index) in list" :key="index">
			<view class="acea-row row-middle row-between top-info" v-if="canClose">
				<view>3天内更新</view>
				<view class="close">×</view>
			</view>
			<view class="acea-row row-middle row-between sell-goods" @click="toPages('/pages/details/supplyChain/supplyChain?id='+item.id)">
				<view class="goods-img">
					<image :src="item.images?item.images.split(',')[0]:''" mode="" class="img"></image>
					<view class="acea-row row-middle distance">
						<image src="@/static/images/location.png" mode=""></image>
						<text>{{kmUnit(item.distance)}}</text>
					</view>
				</view>
				<view class="acea-row row-column-between goods-info">
					<view class="title line1">
						供应链 | {{item.title}}
					</view>
					<view class="acea-row row-middle">
						<view class="transfer-price">{{item.commodity_num}}件</view>
						<view class="sell-price">
							<text>{{item.commodity_price}}</text>元/月
						</view>
					</view>
					<!-- <view class="gold-coin">
						<image src="@/static/images/goldcoin_icon.png" mode=""></image>
						<view class="num">25800</view>
					</view> -->
					<view class="acea-row goods-tag">
						<view class="tag-tit">服务特色：</view>
						<view class="tag" v-for="tags in item.service_characteristics?item.service_characteristics.split(','):[]" :key="tags">{{tags}}</view>
					</view>
				</view>
			</view>
			<!-- 适合场所 -->
		<!-- 	<view class="suitable-box">
				<text class="suitable">酒吧</text>
				<text class="suitable">KTV</text>
				<text class="suitable">休闲娱乐</text>
				<text class="suitable">酒吧</text>
				<text class="suitable">休闲娱乐</text>
			</view>
 -->
			<view class="acea-row row-middle row-between visit-box">
				<view class="visit-advtar-box">
				<!-- 	<view class="visit-advtar">
						<image src="@/static/images/f.png" mode="" v-for="(item,index) in visitInfo" :key="index"
							:style="{left: (30 * index) + 'rpx'}"></image>
					</view>
					<view class="visit-num">18288人浏览 已成功匹配12254人</view> -->
				</view>

				<view class="visit-l">
					<!-- <view class="visit-num">5866人咨询</view> -->
					<view class="visit-btn" @click="toConcat(item.contacts)">
						立即咨询
					</view>
				</view>
			</view>
		</view>


	</view>
</template>

<script>
	export default {
		// 商铺专区列表项
		name: 'shopArea',
		props: {
			list: {
				type: Array,
				default: () => {
					return [1, 1, 1]
				}
			},
			canClose: {
				type: Boolean,
				default: () => {
					return false
				}
			},
			detail: {
				type: Object,
				default: () => {
					return {}
				}
			}
		},
		data() {
			return {
				visitInfo: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
			}
		},
		methods: {
			toConcat(contact) {
				if (!contact || contact.length < 1) {
					this.$util.Tips({
						title: '暂未获取到联系人'
					})
					return;
				}

				getApp().globalData.into_singleChatRoom({
					phone:contact[0].contactPhone,
					contactId:contact[0].contactId,
				})
			},
			kmUnit(m) {
				m = Number(m)
				var v;
				if (typeof m === 'number' && !isNaN(m)) {
					if(m>10000){
						m = 0;
					}
					if (m >= 1) {
						v = m.toFixed(2) + 'km'
					} else {
						v = (m*1000).toFixed(2) + 'm'
					}
				} else {
					v = '0m'
				}
				return v;
			},
			toPages(path) {
				uni.navigateTo({
					url: path
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import "@/components/listItems/index.scss";
</style>